package com.rk.admin.controller;


import com.rk.admin.domain.ApiCount;
import com.rk.admin.domain.Images;
import com.rk.admin.service.ApiService;
import com.rk.admin.tools.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.*;

@Api(tags = "文章访问次数统计")
@RestController
@CrossOrigin //前后端分离配置跨域访问
@RequestMapping("/apiais")
public class ApiVisCountController {

    //服务对象
    @Autowired
    private ApiService apiService;



    @GetMapping("/findcount")
    @ApiOperation(("页面访问次数"))
    public CommonResult findcount(){
        List<ApiCount> apimap = apiService.find(7);

        List<Integer>  listcount = new ArrayList<>();
        List<Date>      listdata= new ArrayList<>();

        for(ApiCount   data : apimap)
        {
            listcount.add(data.getCounts());
            listdata.add(data.getDaydata());
        }

        Map<String,List> map = new HashMap<String,List>();
        map.put("dtacount",listcount);
        map.put("datatime",listdata);
        return CommonResult.success(map);
    }

}
